export default {
    install(Vue){
        Vue.mixin({
            methods:{
                localSetObject(name,data){//对象与数组数据
                    localStorage.setItem(name,JSON.stringify(data));
                },
                localGetObject(name){
                    return JSON.parse(localStorage.getItem(name));
                },
                localSet(name,data){//普通数据
                    localStorage.setItem(name,data);
                },
                localGet(name){
                    return localStorage.getItem(name);
                },
                notifyMsgErr(msg){//返回Element错误信息对象
                    return {
                        title: '错误！',
                        message: msg || '未知错误',
                        showClose: true
                    }
                },
                notifyMsgSuc(msg){//返回Element成功信息对象
                    return {
                        title: '成功！',
                        message: msg,
                        showClose: true
                    }
                },
                userImage(email){//返回用户QQ头像链接
                    let qq=email.split('@')[0];
                    let src=['https://qlogo2.store.qq.com/qzone/','/100'];
                    return src[0]+qq+'/'+qq+src[1];
                }
            },
            data(){
                return{
                    userObjectName:'user',//用户对象保存的本地key

                    userNameCheck:/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/,
                    userEmailCheck:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,

                    articleEditTemplate:'article',
                    articleSaveImageIds:'editSaveImageIds',
                    imageCheck:/\.(png|jpg|gif|jpeg|webp)$/,
                    imageAddress:"http://127.0.0.1:8081/upload/image/",
                    optionsLevel:[
                        {
                            label:'站长',
                            value:true
                        },
                        {
                            label:'游客',
                            value:false
                        }
                    ]
                }
            }
        })
    }
}
